<template>
    <view class="" :tab="tab"><u-tabbar v-model="current" :list="list" :mid-button="false" @change="onClick"></u-tabbar></view>
</template>

<script>
export default {
    props: {
        tab: {
            type: Object,
            default: function() {
                return {};
            }
        }
    },
    data() {
        return {
            list: [
                {
                    iconPath: '/static/tabbar/home.png',
                    selectedIconPath: '/static/tabbar/home.png',
                    text: '首页',
                    customIcon: false,
                    pagePath: '/pages/home/home'
                },
                {
                    iconPath: '/static/tabbar/phone.png',
                    selectedIconPath: '/static/tabbar/phone.png',
                    text: '联系',
                    customIcon: false
                }
            ],
            current: 0
        };
    },
    methods: {
        onClick(index) {
            console.log();
            switch (index) {
                case 1:
                    uni.makePhoneCall({
                        phoneNumber: '18381532620' //仅为示例
                    });
                    break;
                default:
                    break;
            }
        },
        addTab() {
            if (this.tab.hasOwnProperty('iconPath') || this.tab.hasOwnProperty('text')) {
                this.list.push(
                    this.tab
                    /* {
                iconPath: '/static/tabbar/article.png',
                selectedIconPath: '/static/tabbar/article.png',
                text: '动态',
                pagePath: '/pages/home/home',
                customIcon: false
            } */
                );
            }
            return;
        }
    },

    mounted() {
        this.addTab();
    }
};
</script>

<style></style>
